<!--密码修改-->
<template>
    <a-modal
            v-model="verionModal"
            title="版本信息"
            :mask-closable="false"
            :closable="false" @cancel="closeModal"
    >
        <div>
            <a-form :label-width="120">
                <a-form-item label="系统名称："  v-bind="formStyle">
                    <span style="">{{systemSrvName}}</span>
                </a-form-item>
                <a-form-item label="软件版本："  v-bind="formStyle">
                    <span style="">{{version}}</span>
                </a-form-item>
            </a-form>
        </div>
        <div slot="footer">
            <a-button type="primary" @click="systemFactorySettings">恢复出厂设置</a-button>
            <a-button type="default" @click="closeModal">取消</a-button>
        </div>
        <div class="spinBox" v-if="spinning">{{spinText}}</div>
    </a-modal>
</template>
<script>
    export default {
        name: 'softVersion',
        data () {
            return {
                verionModal: false,
                systemSrvName: sessionStorage.getItem ('systemSrvName'),
                issueTime: '',
                localQccsId: sessionStorage.getItem ('localQccsId'),
                version:'',
                spinning:false,
                spinText:'请稍后...',
            }
        },
        computed: {
            formStyle () {
                return this.$store.state.common.formStyle
            },},
        methods: {

            /**
             * Function    : showModal
             * Description : 显示窗口
             * Input       : none
             * Return      : none
             */
            showModal () {
                let _this = this
                _this.verionModal = true
                _this.$get('api/system/loadSystemInfo').then (res => {
                    this.version = res.data.version
                    this.systemSrvName = res.data.systemName
                })
            },

            /**
             * Function    : closeModal
             * Description : 关闭窗口
             * Input       : none
             * Return      : none
             */
            closeModal () {
                this.verionModal = false
            },
            systemFactorySettings(){
                this.$confirm ({
                    title: `确定恢复出厂设置吗?`,
                    okText: '确定',
                    cancelText: '取消',
                    onOk: () => {
                        let _this = this
                        _this.spinning = true
                        _this.$get ('api/system/systemFactorySettings').then (res => {
                            _this.spinning = false
                            if (res.code === 0) {
                                _this.verionModal = false
                                sessionStorage.clear();
                                _this.$message.success('恢复出厂设置成功，请重新登录')
                                this.$router.push({
                                    name: 'login'
                                });
                            } else {
                                _this.$message.error (res.message)
                            }
                        })
                    }
                })
            }
        }
    }
</script>
